package binlog.listener;

import com.github.shyiko.mysql.binlog.BinaryLogClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 连接状态监听器
 */

@Component
@Slf4j
public class BinlogLifecycle implements BinaryLogClient.LifecycleListener {
    @Override
    public void onConnect(BinaryLogClient client) {
        log.info("已连接: ");
    }

    @Override
    public void onCommunicationFailure(BinaryLogClient client, Exception ex) {
        log.info("网络异常,通讯失败: ",ex);
    }

    @Override
    public void onEventDeserializationFailure(BinaryLogClient client, Exception ex) {
        log.info("反序列化失败: ",ex);
    }

    @Override
    public void onDisconnect(BinaryLogClient client) {
        log.info("已断开: ");
    }
}
